<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>全部文章</title>
  <style>
    body {
      font-family: 'Arial', sans-serif;
      margin: 0;
      padding: 0;
      background-color: #f9f9f9;
      color: #333;
      font-size: 16px;
      line-height: 1.6;
    }

    .container {
      max-width: 1200px;
      margin: 20px auto;
      padding: 20px;
      background-color: #fff;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      border-radius: 8px;
      overflow: hidden;
    }

    h1 {
      text-align: center;
      color: #333;
      margin-bottom: 20px;
    }

    .section {
      padding: 20px;
      border-radius: 8px;
      background-color: #fff;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    h2 {
      color: #333;
      border-bottom: 2px solid #eee;
      padding-bottom: 10px;
      margin-bottom: 20px;
    }

    .blog-posts {
      list-style: none;
      padding: 0;
    }

    .blog-posts li {
      margin-bottom: 20px;
      padding: 15px;
      background-color: #fafafa;
      border-radius: 6px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    }

    .blog-posts li:hover {
      transform: translateY(-5px);
      box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    }

    .blog-posts a {
      text-decoration: none;
      color: #007BFF;
      font-size: 24px;
      margin-bottom: 10px;
      display: block;
    }

    .blog-posts p {
      font-size: 16px;
      color: #666;
    }

    .footer {
      padding: 20px;
      text-align: center;
      background-color: #333;
      color: white;
      margin-top: 20px;
    }

    .back-home {
      display: inline-block;
      margin-top: 20px;
      padding: 10px 20px;
      background-color: #007BFF;
      color: #fff;
      text-decoration: none;
      border-radius: 5px;
      transition: background-color 0.3s ease;
    }

    .back-home:hover {
      background-color: #0056b3;
    }

    .pagination {
      display: flex;
      justify-content: center;
      margin-top: 20px;
    }

    .pagination a {
      margin: 0 10px;
      padding: 5px 10px;
      background-color: #007BFF;
      color: #fff;
      text-decoration: none;
      border-radius: 5px;
      transition: background-color 0.3s ease;
    }

    .pagination a:hover {
      background-color: #0056b3;
    }

    .no-articles {
      text-align: center;
      color: #666;
    }

    .article-title {
      font-size: 24px;
      margin-bottom: 10px;
    }

    .article-author {
      font-size: 16px;
      color: #666;
      margin-bottom: 10px;
    }

    .article-info {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
    }

    .article-date {
      font-size: 14px;
      color: #666;
    }

    .read-more {
      padding: 5px 10px;
      background-color: #007BFF;
      color: #fff;
      text-decoration: none;
      border-radius: 5px;
      transition: background-color 0.3s ease;
    }

    .read-more:hover {
      background-color: #0056b3;
    }
  </style>
</head>
<body>

<div class="container">
  <h1>搜索结果</h1>
  <!-- 显示文章列表 -->
  <ul class="article-list">
    <li th:if="${articles == null or articles.isEmpty()}" class="no-articles">
      <p>没有找到相关的文章。</p>
    </li>
    <li th:each="article : ${articles}" class="article-item">
      <h2 class="article-title" th:text="${article.title}"></h2> <!-- 显示文章标题 -->
      <p class="article-author" th:text="'作者: ' + ${article.username}"></p>
      <div class="article-info">
        <p class="article-date" th:text="'发布日期: ' + ${article.updatetime}"></p>
        <a th:href="@{'/articles/' + ${article.id}}" class="read-more">阅读全文</a>
      </div>
    </li>
  </ul>
  <div class="pagination">
    <span th:if="${currentPage > 0}">
        <a th:href="@{/tagName(tagName=${tagName}, page=${currentPage - 1})}" class="back-home">上一页</a>
    </span>
    <span th:text="'当前页：' + ${currentPage + 1} + ' / ' + ${totalPages}"></span>
    <span th:if="${currentPage < totalPages - 1}">
        <a th:href="@{/tagName(tagName=${tagName}, page=${currentPage + 1})}" class="back-home">下一页</a>
    </span>
  </div>
  <a class="back-home" href="/login/goToBlog">返回主页</a>
</div>
